import 'dart:ffi';

import 'package:flutter/material.dart';

///卡片 card
///

class CardDemo extends StatefulWidget {
  const CardDemo({Key? key}) : super(key: key);

  @override
  _CardDemoState createState() => _CardDemoState();
}

class _CardDemoState extends State<CardDemo> {
  List<Map> _list = [];

  @override
  void initState() {
    for (int i = 1; i < 10; i++) {
      _list.add({
        "age": 10 + i,
        "name": "name $i",
      });
    }
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    Widget _itemBuilder(BuildContext context, int index) {
      return Card(
        // color: Colors.blue,
        shadowColor: Colors.red,
        elevation: 4,
        child: Column(
          children: [
            SizedBox(height: 16),
            Text(_list[index]["age"].toString()),
            SizedBox(height: 16),
            Text(_list[index]["name"]),
            SizedBox(height: 16)
          ],
        ),
      );
    }

    return Scaffold(
      appBar: AppBar(
        title: Text("卡片"),
        centerTitle: true,
      ),
      body: Padding(
        padding: EdgeInsets.all(10),
        child: ListView.builder(
            itemBuilder: _itemBuilder, itemCount: _list.length),
      ),
    );
  }
}
